const { resolve } = require('path')
const { merge } = require('webpack-merge')
const baseConfig = require('./webpack.base.js')

const config = baseConfig({ mode: 'development' })

const interfaces = require('os').networkInterfaces(); // 在开发环境中获取局域网中的本机iP地址
let IPAdress = '';
for (var devName in interfaces) {
  var iface = interfaces[devName];
  for (var i = 0; i < iface.length; i++) {
    var alias = iface[i];
    if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) {
      IPAdress = alias.address;
    }
  }
}

const devConfig = {
  mode: 'development',
  devServer: {
    // host: IPAdress,
    host: 'localhost',
    port: '5000',
    open: true,
    compress: true,
  }
}

module.exports = merge(config, devConfig)